<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
	</head>
        
        
	<body>
            <div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">INPUT STUDENT GRADES</a></li>
                                        <li><a href="view.php">BACK</a></li>
				
				</ul>
			</div>
			<div class="body">
                          

                                    <?php

                                     include 'PHPClasses/DBAccess.php';
                                     include 'PHPClasses/StudentDBAccess.php';
                                     
                                     error_reporting (E_ALL ^ E_NOTICE);
                                   
                                         

                                            $oldgrades=$_POST['oldgrades'];
                                            $newgrades=$_POST['newgrades'];
                                            $gradeCriteria=$_POST["gradeCriteria"];
                                            $subjectID=$_POST["subjectID"];
                                            $studentID=$_POST["studentID"];
                                            $gradeid=$_POST["idgrade"];
                                            
                                           
                                      
                                         $DBAccess = new StudentDBAccess();
                                         
                                         $errormsg=$DBAccess->validationofgrade($newgrades,$gradeCriteria,$oldgrades);
                                               
                                          if ($errormsg){ //If any errors display them  
                                                header("Location: http://localhost/paragox-infinity-introse/inputStudentGrade.php?error=".$errormsg."&subjectID=".$subjectID."&studentID=".$studentID."");
                                            }
                                            else
                                            {
                                                 $DBAccess->updategrade($oldgrades,$gradeid,$gradeCriteria);
                                                 $DBAccess->addgrade($newgrades,$gradeCriteria,$subjectID,$studentID);
                                                  echo "<script> 
                                                    if(confirm('Grades added! Go back to profile?')){
                                                    window.location='http://localhost/paragox-infinity-introse/viewStudentprofile.php?studentID=".$studentID."';
                                                         }
                                                    else{
                                                             window.location='http://localhost/paragox-infinity-introse/inputStudentGrade.php?subjectID=".$subjectID."&studentID=".$studentID."';
                                                      }   
               
                                                                    </script>"; 
                                            }             
                                          
                    ?>
                         
                        </div>
                    
			
		</div>
            
                                       
			
	</body>
</html>  


